<template>
  <img src="../../../../static/staticJC/images/event/Qchart.png" alt="" class="Qchart" @click="clickChest">
</template>

<script>
  export default {
    computed:{
      windowWidth() {
        return this.$store.state.windowWidth
      },
      windowHeight() {
        return this.$store.state.windowHeight
      }
    },
    methods:{
      /**
       * 点击显示二维码ID
       * **/
      clickChest(needScore, type,index,e) {
        var _self = this;
        ajaxCore.ajax(config.szg.getUserNumber, null, "GET", {
          "Authorization": getToken()
        }).done((res) => {
          if (res.status == 10001) {
              //画二维码
              $("#code").empty();
              if(!$("#code")[0]){
                $('.szg_chest4').after($('<div id="code"></div>'))
              }

              var str = res.result;
              $("#code").qrcode({

                width: this.windowWidth * .5,

                height: this.windowWidth * .5,

                text: str

              });

              layer.open({
                type: 1,
                content: $("#code"),
                title: false,
                shade: false,
                anim: 5,
                btn: false
              });
          }
        })
        function toUtf8(str) {

          var out, i, len, c;

          out = "";

          len = str.length;

          for (i = 0; i < len; i++) {

            c = str.charCodeAt(i);

            if ((c >= 0x0001) && (c <= 0x007F)) {

              out += str.charAt(i);

            } else if (c > 0x07FF) {

              out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));

              out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));

              out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));

            } else {

              out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));

              out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));

            }

          }

          return out;

        }

      },
    }
  }
</script>

<style>

</style>
